﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Food.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Food.VariableTemplate
{
    public class VariableTiles:DataTemplateSelector
    {
        public DataTemplate TodaysTemplate { get; set; }
        public DataTemplate BigTemplate { get; set; }
        public DataTemplate CuisinesTemplate { get; set; }
        public DataTemplate IngregientTemplate { get; set; }
        public DataTemplate MediumTemplate { get; set; }
        public DataTemplate AddonTemplate { get; set; }
        public DataTemplate SmallTemplate { get; set; }
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        { 
            FrameworkElement element = container as FrameworkElement;
            if (element != null && item != null)
            {
                if (item.GetType() == typeof(SampleDataItem1))
                {
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Todays"))
                        return TodaysTemplate;
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Big"))
                        return BigTemplate;
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Cuisines"))
                        return CuisinesTemplate;
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Ingregient"))
                        return IngregientTemplate;
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Medium"))
                        return MediumTemplate;
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Addon"))
                        return AddonTemplate;
                    if ((item as SampleDataItem1).UniqueId.StartsWith("Small"))
                        return SmallTemplate;

                }
                else if (item.GetType() == typeof(SampleDataItem3))
                {
                    if ((item as SampleDataItem3).UniqueId.StartsWith("Big"))
                        return BigTemplate;
                    if ((item as SampleDataItem3).UniqueId.StartsWith("Medium"))
                        return MediumTemplate;

                }
                else if (item.GetType() == typeof(SampleDataItem4))
                {
                    if ((item as SampleDataItem4).UniqueId.StartsWith("Big"))
                        return BigTemplate;
                    if ((item as SampleDataItem4).UniqueId.StartsWith("Medium"))
                        return MediumTemplate;

                }
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}

